package NWish.properties.object3ds.filters3d
{
	import NWish.Interface.ILogger;
	
	import NWish.json.OrderDict;
	import NWish.properties.Properties;
	
	import away3d.containers.Scene3D;
	import away3d.filters.DepthOfFieldFilter3D;
	
	import NWish.Interface.ILogger;
	
	
	public class DepthOfFieldFilter3DProperties extends Properties
	{
		public function DepthOfFieldFilter3DProperties(parent)
		{
			super(parent);
			
			var keys
			= 
				['focusDistance'
				,'range'
				,'maxBlurX'
				,'maxBlurY'
				];
			addPropertieKeys(null,keys);
		}
		
		override public function toString()
		{
			return 'DepthOfFieldFilter3D';
		}
		
		override public function get type()
		{
			return DepthOfFieldFilter3D;
		}
		
		override public function propertiesToDict(obj,dict:OrderDict,read_only = false,saving = false)
		{
			super.propertiesToDict(obj,dict,read_only,saving)

			if(read_only == false)
			{
				if(saving == false)
				{
					if(obj.focusTarget)
						dict.push(Properties.readMark + 'currfocusTarget',obj.focusTarget.name);
						
					dict.push('focusTarget','');
				}
			}
		}
		
		override public function dictToProperties(dict,obj,scene:Scene3D,isloading)
		{
			super.dictToProperties(dict,obj,scene,isloading);

			var target = dict['focusTarget'];
			if(target == null)
			{
				obj.focusTarget = null;
			}
			else if(target.length > 0)
			{
				var obj3d = getObject3d(target);
				if(obj3d)
					obj.focusTarget = obj3d;
				else
					ILogger.log('can not find the object ' + target);
			}
		}
	}
}